;; The first four lines of this file were added by Dracula.
;; They tell DrScheme that this is a Dracula Modular ACL2 program.
;; Leave these lines unchanged so that DrScheme can properly load this file.
#reader(planet "reader.rkt" ("cce" "dracula.plt") "modular" "lang")
(require "Istockretrieval.lisp")
(require "Mstock-retrieval.lisp")
(require "M-avl-string-keys.lisp")
(require "mhelpers.lisp")

(module Tstockretrieval
  (import Istockretrieval)
  (import Itree)
  
  ; check-expect tests  
  (include-book "testing" :dir :teachpacks)
  
  ; get-stocks-in-range-by-ticker
  (check-expect (get-stocks-in-range-by-ticker (avl-insert (empty-tree) "20111025" (avl-insert (empty-tree) "JOSH" 
                                                                                               '(41.83 42.29 41 41.22 10857))) "20111025" "20120101" "JOSH") '(("JOSH" 41.83 42.29 41 41.22 10857)))
  (check-expect (get-stocks-in-range-by-ticker (empty-tree) "20111025" "20120101" "JOSH") nil)
  
  ; get-stocks-in-range-by-tickers
  (check-expect (get-stocks-in-range-by-tickers (avl-insert (empty-tree) "20111025" (avl-insert (empty-tree) "JOSH" 
                                                                                                '(41.83 42.29 41 41.22 10857))) "20111025" "20120101" '("JOSH")) '(("JOSH" 41.83 42.29 41 41.22 10857)))
  (check-expect (get-stocks-in-range-by-tickers (empty-tree) "20111025" "20120101" '("JOSH")) nil)
  
  ; get-stocks-in-range
  (check-expect (get-stocks-in-range (avl-insert (empty-tree) "20111025" (avl-insert (empty-tree) "JOSH" 
                                                                                     '(41.83 42.29 41 41.22 10857))) "20111025" "20120101") '(("JOSH" 41.83 42.29 41 41.22 10857)))
  (check-expect (get-stocks-in-range (empty-tree) "20111025" "20120101") nil)
  
  ; get-first-in-range
  (check-expect (get-first-in-range (avl-insert (empty-tree) "20111025" (avl-insert (empty-tree) "JOSH" 
                                                                                    '(41.83 42.29 41 41.22 10857))) "20111025" "20120101" "JOSH") '("JOSH" 41.83 42.29 41 41.22 10857))
  (check-expect (get-first-in-range (empty-tree) "20111025" "20120101" "JOSH") nil)
  
  ; get-last-in-range
  (check-expect (get-last-in-range (avl-insert (empty-tree) "20111025" (avl-insert (empty-tree) "JOSH" 
                                                                                   '(41.83 42.29 41 41.22 10857))) "20111025" "20120101" "JOSH") '("JOSH" 41.83 42.29 41 41.22 10857))
  (check-expect (get-last-in-range (empty-tree) "20111025" "20120101" "JOSH") nil)
  
  ; get-all-tickers-helper
  (check-expect (get-all-tickers-helper '(("JOSH" 1 1 1 1 1 1) ("JOSH" 2 2 2 2 2 2) ("JOSH" 3 3 3 3 3))) 
                '("JOSH" "JOSH" "JOSH"))
  (check-expect (get-all-tickers-helper nil) nil)
  
  ; get-all-tickers
  (check-expect (get-all-tickers '(("JOSH" 1 1 1 1 1 1) ("JOSH" 2 2 2 2 2 2) ("JOSH" 3 3 3 3 3))) 
                '("JOSH"))
  (check-expect (get-all-tickers nil) nil)
  
  
  
  )

(link RTstockretrieval (Mtree Mstockretrieval Tstockretrieval))
(invoke RTstockretrieval)